package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api(tags = "商品状态管理")
@Slf4j
public class shopcotroller {
    private final String key ="shop_status";

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;
    @ApiOperation("商家设置状态")
    @PutMapping("/{status}")
    public Result setShopstatus(@PathVariable Integer status)
    {

        log.info("设置商店状态为：{}",status);
        //设置店门状态
        redisTemplate.opsForValue().set(key,status);
        return  Result.success();
    }
    @GetMapping("/status")
    @ApiOperation("获取店门状态")
    public Result<Integer> getshopstatus()
    {
        Object status = redisTemplate.opsForValue().get(key);
        return Result.success((Integer) status);
    }


}
